package com.itheima.redbaby.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.itheima.redbaby.BaseActivity;
import com.itheima.redbaby.R;
import com.itheima.redbaby.bean.Logistics;
import com.itheima.redbaby.engine.OrderEngine;
import com.itheima.redbaby.factory.DaoAndEngineFactory;

public class OrderLogisticsActivity extends BaseActivity  {
	
	

	private TextView textAdress1;
	private TextView textAdress2;
	private TextView textAdress3;
	private TextView textAdressKey4;
	private TextView head_back_text;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.order_logistics_info);
		
		//获取传递过来的orderId
		Intent intent = getIntent();
		Bundle extras = intent.getExtras();
		String orderId = extras.getString("orderId");
		
		initView();
		getData(orderId);
		
	}

	private void getData(final String orderId) {
		new MyHttpTask() {
			
			@Override
			protected Object doInBackground(Void... params) {
				OrderEngine impl = DaoAndEngineFactory.getImpl(OrderEngine.class);
				Logistics logistics = impl.getLogistics(orderId);
				
				return logistics;
			}
			protected void onPostExecute(Object result) {
				if(result!=null){
					Logistics log=(Logistics)result;
				textAdress1.setText(log.getExpressway());
				textAdress2.setText(log.getLogisticsid());
				textAdress3.setText(log.getLogisticscorp());
				textAdressKey4.setText(log.getList());
				}
				
			};
		}.executeHttp();
		
	}

	private void initView() {
		textAdress1 = (TextView) findViewById(R.id.textAdress1);
		textAdress2 = (TextView) findViewById(R.id.textAdress2);
		textAdress3 = (TextView) findViewById(R.id.textAdress3);
		textAdressKey4 = (TextView) findViewById(R.id.textAdressKey4);
		head_back_text = (TextView) findViewById(R.id.head_back_text);
		
		head_back_text.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
		
	}


}
